using UnityEngine;

public class BakeMesh : MonoBehaviour
{
    public SkinnedMeshRenderer renderer;
    
    [ContextMenu("BakeSkin")]
    void BakeSkin()
    {
        Mesh mesh = new Mesh();
        renderer.BakeMesh(mesh);
        mesh.name = renderer.name;

        MeshFilter filter = gameObject.GetComponent<MeshFilter>();
        if(filter == null)
            filter = gameObject.AddComponent<MeshFilter>();
        filter.sharedMesh = mesh;
        //gameObject.AddComponent<MeshRenderer>();
    }
}